package com.huixin.powermonitor.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
//控制上传与下载的路径
public class GetPath {
    @Autowired
    private ApplicationContext applicationContext;
    //获取上传相对路径
    public String getProjectPath() throws IOException {
        ResourceLoader resourceLoader = applicationContext;
        Resource resource = resourceLoader.getResource("classpath:");
        return resource.getFile().getParentFile().getParentFile().getAbsolutePath()+"\\src\\main\\resources\\static";
    }

}